﻿using FangPage.Common;
using FangPage.Core;
using ProjectManager.User.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;

namespace ProjectManager.User
{
    public class Logins
    {
        public static AuthInfo Authorize()
        {
            AuthInfo authinfo = new AuthInfo();

            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                authinfo.islogin = true;
                authinfo.username = HttpContext.Current.User.Identity.Name;
                authinfo.userid= HttpContext.Current.User.FindFirstValue("userid");
                authinfo.token = HttpContext.Current.User.FindFirstValue("token");
                authinfo.realname = HttpContext.Current.User.FindFirstValue("realname");
                authinfo.roleid = HttpContext.Current.User.FindFirstValue("roleid");
                authinfo.rolename = HttpContext.Current.User.FindFirstValue("rolename");
                authinfo.departid = HttpContext.Current.User.FindFirstValue("departid");
                authinfo.departname = HttpContext.Current.User.FindFirstValue("departname");
                authinfo.departs = HttpContext.Current.User.FindFirstValue("departs");
                authinfo.isadmin =FPUtils.ToShort(HttpContext.Current.User.FindFirstValue("isadmin"));
            }

            return authinfo;
        }
    }
}
